/*
 * Open LiveReplay Server - Live replay server for Supreme Commander
 * 
 * Copyright (C) 2009, 2009 Open LiveReplay Server Project
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details:
 * http://www.gnu.org/copyleft/lesser.html#TOC3
 */
package net.galacticwar.lua;

import java.io.IOException;
import java.io.StreamTokenizer;


/**
 * A Java object corresponding to a Vector3 LUA object.
 * 
 * @author Yoann Meste (aka Mancer)
 *
 */
public class LuaVector3 {
	private float val1, val2, val3;
	
	public LuaVector3(StreamTokenizer st) throws IOException{
		extract(st);
	}
	
	public LuaVector3(float val1, float val2, float val3) {
		this.val1 = val1;
		this.val2 = val2;
		this.val3 = val3;
		
	}
	
	
	
	public float getVal1() {
		return val1;
	}

	public float getVal2() {
		return val2;
	}

	public float getVal3() {
		return val3;
	}

	private void extract(StreamTokenizer st) throws IOException{
		st.nextToken();
		st.nextToken();
		st.nextToken();
		val1 = (float) st.nval;
		st.nextToken();
		st.nextToken();
		st.nextToken();
		val2 = (float) st.nval;
		st.nextToken();
		st.nextToken();
		st.nextToken();
		val3 = (float) st.nval;
		st.nextToken();
		st.nextToken();

	}
	
	@Override
	public String toString() {
		return "( " + val1 + ", " + val2 + ", " + val3 + " )";
	}
}
